package sentinel.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.sql.Time;
import java.util.concurrent.TimeUnit;

/**
 * @author cyt
 * @create 2020-06-03 15:18
 */
@Slf4j
@RequestMapping("/sentinel")
@RestController
public class SentinelController {

    @GetMapping("/testA")
    public String TestA() {
        try {
            TimeUnit.MILLISECONDS.sleep(500);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "TestA";
    }

    @GetMapping("/testB")
    public String testB() {

        return "testB";
    }

    @GetMapping("/testC")
    public String testC() {
        int a = 10 / 0;
        log.info("测试异常的比例");
        return "testC";
    }

    @GetMapping("/testD")
    public String testD() {

        try {
            TimeUnit.SECONDS.sleep(1);
        } catch (Exception e) {
            e.printStackTrace();
        }
        log.info("测试异常RT");
        return "testD";
    }

    @GetMapping("/testE")
    public String testE() {
        int a = 10 / 0;
        return "testE";
    }



}
